import 'dart:ffi';
import 'dart:math';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:game2048/digital_evolution/login_page.dart';
import 'package:shared_preferences/shared_preferences.dart';

// void main() {
//   runApp(const MaterialApp(home: Game2048()));
// }
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();
  runApp(
    EasyLocalization(
      supportedLocales: [Locale('en', ''), Locale('zh', '')],
      path: 'assets/translations',
      fallbackLocale: Locale('en', ''),
      child: MyApp(),
    ),
  );
  
}

class GameService {
  static final String _levelKey = 'level';

  static Future<bool> saveLevel(int level) async {
    final prefs = await SharedPreferences.getInstance();
    return await prefs.setInt(_levelKey, level);
  }

  static Future<int?> getLevel() async {
    final prefs = await SharedPreferences.getInstance();
    final int? level = prefs.getInt(_levelKey); // 默认值为0
    return level;
  }
}
